import 'package:appflutterhomeschool/res/styles.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///用户：Nine Tailed Fox
///时间：2020/6/10
///邮箱：1037438704@qq.com
///功能：所有按钮
class SureMaterialButton extends StatelessWidget {
  final VoidCallback onPressed;
  final String buttonName;
  final double buttonHeight;

  SureMaterialButton({this.onPressed, this.buttonName, this.buttonHeight});

  @override
  Widget build(BuildContext context) {
    TextStyle textStyle =
    TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(43));
    return MaterialButton(
      minWidth: double.infinity,
      //按钮失效时的颜色
      disabledColor: Colors.grey,
      //按钮背景色
      color: Colors.blue,
      //点击按钮时水波纹颜色
//      splashColor: ColorHelper.mainPressBlueColor,
      //长按后的颜色
//      highlightColor: ColorHelper.disableColor,
      //阴影的范围，值越大阴影范围越大
//        elevation: 100.0,
      shape: StadiumBorder(),
      padding: EdgeInsets.only(top: 10, bottom: 10),
      child: Text(
        buttonName ?? "确定",
        style: textStyle,
      ),
      onPressed: onPressed,
    );
  }
}

class ButtonWidget {
  static ButtonWidget _buttonWidget;

  static ButtonWidget getButtonWidget() {
    return _buttonWidget == null
        ? _buttonWidget = ButtonWidget._buttonWidget
        : _buttonWidget;
  }

  //长方形按钮
  Widget rectangleButtonWidget(
      {String buttonName, TextStyle textStyle, VoidCallback onPressed,Color bgColor}) {
    return Container(
      height: ScreenUtil().setWidth(115),
      child: MaterialButton(
        minWidth: double.infinity,
        //按钮失效时的颜色
        disabledColor: Colors.grey,
        //按钮背景色
        color: bgColor??Colors.blue,
        //点击按钮时水波纹颜色
//      splashColor: ColorHelper.mainPressBlueColor,
        //长按后的颜色
//      highlightColor: ColorHelper.disableColor,
        //阴影的范围，值越大阴影范围越大
//        elevation: 100.0,
//      shape: StadiumBorder(),
//      padding: EdgeInsets.only(top: 10, bottom: 10),
        child: Text(
          buttonName ?? "确定",
          style: textStyle ?? TextStyles.textWhite43,
        ),
        onPressed: onPressed,
      ),
    );
  }
  //椭圆按钮
  Widget ellipseButtonWidget(
      {double heightDouble,double widthDouble,String buttonName, TextStyle textStyle, VoidCallback onPressed}) {
    return MaterialButton(
      height:heightDouble?? ScreenUtil().setWidth(69),
      minWidth:widthDouble?? ScreenUtil().setWidth(215),
      //按钮失效时的颜色
      disabledColor: Colors.grey,
      //按钮背景色
      color: Colors.blue,
      //点击按钮时水波纹颜色
//      splashColor: ColorHelper.mainPressBlueColor,
      //长按后的颜色
//      highlightColor: ColorHelper.disableColor,
      //阴影的范围，值越大阴影范围越大
//        elevation: 100.0,
      shape: StadiumBorder(),
//      padding: EdgeInsets.only(top: 10, bottom: 10),
      child: Text(
        buttonName ?? "确定",
        style: textStyle ?? TextStyles.textWhite29,
      ),
      onPressed: onPressed,
    );
  }

  //圆角
  Widget filletButtonWidget(
      {String buttonName, TextStyle textStyle, VoidCallback onPressed}) {
    return RaisedButton(
      onPressed: onPressed,
      color: Colors.blue,
      child: Container(
        width: double.maxFinite,
        alignment: Alignment.center,
        child: Text(buttonName??"浮动按钮",style: textStyle??TextStyles.textWhite37,),
      ),
    );
  }

  ///buttonName 名字
  ///onPressed 点击事件
  ///widthDouble 宽度
  ///heightDouble 高度
  ///边框颜色  borderSideColor
  Widget outlineButtonWidget(
      {String buttonName, VoidCallback onPressed, double widthDouble, double heightDouble, Color borderSideColor,TextStyle textStyle}) {
    return Container(
      height: heightDouble ?? ScreenUtil().setWidth(69),
      width: widthDouble ?? ScreenUtil().setWidth(215),
      child: OutlineButton(
        borderSide: BorderSide(color: borderSideColor ?? Colors.grey),
        child: Text(
          buttonName ?? '',
          style: textStyle??TextStyles.textDark29,
        ),
        onPressed: onPressed,
      ),
    );
  }


  Widget ellipseFrameButton(
      {String buttonName, VoidCallback onPressed, double widthDouble, double heightDouble, Color borderSideColor,TextStyle textStyle}) {
    return Container(
      child: OutlineButton(
        shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(50))
        ),
        borderSide: BorderSide(color: borderSideColor ?? Colors.grey),
        child: Text(
          buttonName ?? '',
          style: textStyle??TextStyles.textDark29,
        ),
        onPressed: onPressed,
      ),
    );
  }



}
